// pages/riding/riding.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    height:0,
    digitalcode:"暂无乘车码",
    start:"暂无",
    startstation: "暂无",
    stop: "暂无",
    stopstation: "暂无",
    flag1: true,
    userInfo: { code: '' },
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;

    var flag1 = that.data.flag1

    var digitalcode = that.data.digitalcode
    var orderId = wx.getStorageSync("orderId")
    // var lineid = wx.getStorageSync("lineid")
    console.log(orderId)
    var userid = wx.getStorageSync("userid")


    wx.request({
      url: app.globalData.url + '/ticketNum/wxTicketNum',
      data: { orderId: options.orderId },
      success: function (res) {
        console.log(res.data)
        var lineid = res.data.lineid
        wx.request({
          url: app.globalData.url + '/actualRoute/actualNumOrder',
          data: { lineid: lineid, userId: userid},
          success: function (res) {
            console.log(res.data)
            // for (var i = 0; i < res.data.length; i++) {
            //   if (res.data[i].id == lineid) {
               
            //     res.data[i].start = res.data[i].sites[0]
            //     res.data[i].stop = res.data[i].sites[res.data[i].sites.length - 1]
            //     res.data[i].sites.splice(0, 1)
            //     res.data[i].sites.splice(res.data[i].sites.length - 1, 1)

                that.setData({
                  start: res.data.uptime,
                  startstation: res.data.upname,
                  stop: res.data.endtime,
                  stopstation: res.data.endname
                })
            //   }
            // }
          }
        })
 
        if (res.data.digitalcode == null || res.data.digitalcode == '') {
          that.setData({
            digitalcode: "暂无乘车码"
          })

        } else {
          that.setData({
            digitalcode: res.data.digitalcode
          })
        }

      }
    })
  
    



    var height = that.data.height
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          height: res.windowHeight
        })
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    


    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {
  
  // },

})